//window.onload = function () {
//  var lists = document.getElementById("ul")
//  var li = lists.getElementsByTagName('li')
//  var div = lists.getElementsByClassName('er')
//
//  for (var i = 0; i < li.length; i++) {
//      li[i].index = i;
//      li[i].onclick = function () {
//          for (var i = 0; i < li.length; i++) {
//              li[i].className = '';
//              div[i].style.display = 'none';
//          };
//          this.className = 'on';
//          div[this.index].style.display = 'block';
//      };
//  };
//};



$(document).ready(function(){
	var token = localStorage.getItem('token');
//	console.log(token)
	
	if (token != "" && token != null){
		$(".tui").show();
		$(".deng").hide();
		$(".zhong").show();
	}else{
		$(".tui").hide();
		$(".deng").show(); 
		$(".zhong").hide();
	}
	
//	退出
	
	$('.tui').click(function(){
		
		var url = window.location.pathname;  
		if(url.indexOf("index.html") >= 0 ) {
			$.ajax({
				url:C.interface.quitInter,
				type:'get',
				dataType:'json',
				data:{
					token:token,
					appId:"gzh"
				},
				success:function(e){
					if(e.code == "10000"){
						localStorage.setItem("token","");
		//				alert('确定退出登陆');
						window.location.reload();
						window.location.href = "html/login.html"
					}
				}
			})
		}else{
			$.ajax({
				url:C.interface.quitInter,
				type:'get',
				dataType:'json',
				data:{
					token:token,
					appId:"gzh"
				},
				success:function(e){
					if(e.code == "10000"){
						localStorage.setItem("token","");
		//				alert('确定退出登陆');
						window.location.reload();
						window.location.href = "login.html"
					}
				}
			})
		}
		
		
	})
	
//	个人中心
	$('.zhong').click(function(){
		
		var url = window.location.pathname;  
		if(url.indexOf("index.html") >= 0 ) {
			window.location.href = "html/back/personal/personal.html"
		}else{
			window.location.href = "back/personal/personal.html"
		}
		
		
	})
	
//搜索
$('.sou').click(function(){
	if($('.seek').val() != ''){
			var url = window.location.pathname;  
			if(url.indexOf("index.html") >= 0 ) {
				var searchVal = $(".seek").val();
				var url = encodeURI("html/seach.html?searchVal="+searchVal);
				window.location.href = url;
			}else{
				var searchVal = $(".seek").val();
				var url = encodeURI("seach.html?searchVal="+searchVal);
				window.location.href = url;
			}
		
	}else{
		
	}
})

	
//	$('.sou').click(function(){
//		var url = window.location.pathname;  
//		if(url.indexOf("index.html") >= 0 ) {
//			var searchVal = $(".seek").val();
//			var url = encodeURI("html/seach.html?searchVal="+searchVal);
//			window.location.href = url;
//		}else{
//			var searchVal = $(".seek").val();
//			var url = encodeURI("seach.html?searchVal="+searchVal);
//			window.location.href = url;
//		}
//	})

	
	
//	$('.lian').click(function(){
//
//		
//		var url = window.location.pathname; 
////		alert(url)
//		if(url.indexOf("index.html") >= 0 ) {
////			alert('首页')
//			var url = window.location.href.replace("index.html",'')
//			window.location.href = url + "html/back/chainTool/chainTool.html"
//		}else if(url.indexOf("newRealTime.html") >= 0 ){
////			alert('实时上新')
//			var url = window.location.href.replace("newRealTime.html",'')
//			window.location.href = url + "back/chainTool/chainTool.html"
//		}else if(url.indexOf("choiceness.html") >= 0 ){
////			alert('精选好货')
//			var url = window.location.href.replace("choiceness.html",'')
//			window.location.href = url + "back/chainTool/chainTool.html"
//		}else if(url.indexOf("discounts.html") >= 0 ){
////			alert('优惠券池')
//			var url = window.location.href.replace("discounts.html",'')
//			window.location.href = url + "back/chainTool/chainTool.html"
//		}else if(url.indexOf("commission.html") >= 0 ){
////			alert('高佣专区')
//			var url = window.location.href.replace("commission.html",'')
//			window.location.href = url + "back/chainTool/chainTool.html"
//		}else if(url.indexOf("seckill.html") >= 0 ){
////			alert('秒杀专区')
//			var url = window.location.href.replace("seckill.html",'')
//			window.location.href = url + "back/chainTool/chainTool.html"
//		}else if(url.indexOf("goodsDetails.html") >= 0 ){
////			alert('详情页')
//			var url = window.location.href.replace("goodsDetails.html",'')
//			window.location.href = url + "back/chainTool/chainTool.html"
//		}else{
////			alert("搜索")
//			var url = window.location.href.replace("seach.html",'')
//			window.location.href = url + "back/chainTool/chainTool.html"
//		}
//	})
	

	
			
})